<template>
  <div>
    <TableData :tableList="list" :pagination="pagination" @changePagination="changePagination" />
  </div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import cloud from '@/utils/cloud'
import TableData from './components/pointLogsView/tableData.vue'
import type { TTable } from './components/pointLogsView/type.dict'

const list = ref<TTable[]>([])
const pagination = ref<{
  total: number
  current: number
  pageSize: number
}>({
  total: 0,
  current: 1,
  pageSize: 10,
})
const getLis = () => {
  cloud
    .callFunction({
      name: 'wx_point_logs',
      data: {
        action: 'admin/point/logs/list',
        params: { pageSize: pagination.value.pageSize, pageNumber: pagination.value.current },
      },
    })
    .then(({ result }) => {
      list.value = result.data.records
      pagination.value.total = result.data.total
    })
    .catch((err) => {
      console.log(err)
    })
}
const changePagination = (paginations: { current: number; pageSize: number }) => {
  pagination.value.current = paginations.current
  pagination.value.pageSize = paginations.pageSize
  getLis()
}
onMounted(() => {
  getLis()
})
</script>
